package com.hmall.search.pojo;

import com.hmall.common.dto.Item;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
public class ItemDoc {
    private Long id; //id
    private String name; //姓名
    private Long price; //价格
    private String image; //图片
    private String category; //种类
    private String brand;  //品牌
    private Integer sold; //销量
    private Integer commentCount;
    private Boolean isAD;
    private List<String> suggestion = new ArrayList<>(2);

    public ItemDoc(Item item){
        //属性拷贝
        BeanUtils.copyProperties(item,this);
        //补全
        suggestion.add(item.getBrand());
        suggestion.add(item.getCategory());
    }

}
